import http from '@/api/http'
import type {
  Draw,
  DrawListData,
  CreateAdminDrawDto,
  UpdateAdminDrawDto,
  DrawIdData,
} from '@/types/draw.api'

// 奖品管理 API
export const listDraws = (params?: {
  name?: string
  subTitle?: string
  page?: number
  size?: number
}): Promise<ApiResponse<DrawListData>> => {
  return http.get<DrawListData>('/admin/draw', { params })
}

export const getDrawDetail = (id: string): Promise<ApiResponse<Draw>> => {
  return http.get<Draw>(`/admin/draw/${id}`)
}

export const createDraw = (
  dto: CreateAdminDrawDto,
): Promise<ApiResponse<DrawIdData>> => {
  return http.post<CreateAdminDrawDto, DrawIdData>('/admin/draw', dto)
}

export const updateDraw = (
  id: string,
  dto: UpdateAdminDrawDto,
): Promise<ApiResponse<DrawIdData>> => {
  return http.patch<UpdateAdminDrawDto, DrawIdData>(`/admin/draw/${id}`, dto)
}

export const deleteDraw = (id: string): Promise<ApiResponse<DrawIdData>> => {
  return http.del<DrawIdData>(`/admin/draw/${id}`)
}